package cn.edu.gdpt.mobile0123456789hwh0526;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class MySQLiteOpenHelper extends SQLiteOpenHelper {
    public MySQLiteOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        String sql="create table users(_id integer primary key autoincrement,name varchar(20) not null,age integer,score float)";
        sqLiteDatabase.execSQL(sql);
        ContentValues values=new ContentValues();
        values.put("name","王小平");
        values.put("age",20);
        values.put("score",80);
        sqLiteDatabase.insert("users",null,values);
        values.put("name","张小菲");
        values.put("age",21);
        values.put("score",88);
        sqLiteDatabase.insert("users",null,values);
        values.put("name","浩建");
        values.put("age",22);
        values.put("score",95);
        sqLiteDatabase.insert("users",null,values);
        values.put("name","沈阳");
        values.put("age",25);
        values.put("score",90);
        sqLiteDatabase.insert("users",null,values);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
}
